/*
 * Copyright (c) 2009 Project E7
 *
 * This file is part of ZebBowling
 *
 * ZebBowling is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ZebBowling is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ZebBowling. If not, see <http://www.gnu.org/licenses/>.
 **/

package org.zebbowling.control;

/**
 * Abstract class implementing ControlHandler to provide a general implementation
 * of the {@link ControlHandler} interface.
 *
 * @author Joel Jauregui
 */
public abstract class Controller implements ControlHandler {
    
    protected boolean threadSuspended, threadDead;

    protected Controller() {
        threadSuspended = threadDead = false;
        }
   
    public synchronized boolean getSuspended() {
        return threadSuspended;
        }

    public synchronized void setSuspened(boolean suspend) {
        threadSuspended = suspend;
        }

    public synchronized void stop() {
        threadDead = true;
        }

    public synchronized boolean threadDead() {
        return threadDead;
        }

    /**
     * Converts a byte to a boolean according to the useage of the ControllerConnection
     * specifications.
     *
     * @param b The byte to be turned into a boolean
     * @return The boolean value of the byte
     */
    protected boolean byteToBool(byte b) {
        return b == 1;
        }

    }
